<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    //es5
/*    function add(a, b) {
        return a+b;
    }
    console.log(add(5,3));
    /!*
    * ES6箭头函数：
    * 1.可以省略function关键字
    * 2.如果函数只有一个语句，可以省略return
    * 继承上下文的this关键字
    * *!/

  let  add2 =  (a, b) =>{
      return a+b;
    }
    console.log(add2(10,20))

    let add3 = (a,b) =>
        a+b;*/

//  继承this上下文
//     非箭头函数的
    let Person = {
        firstName: '张',
        lastName: "飞",
        getFullName:function () {
            console.log(this);
            let first = this.firstName;
            console.log(first);
            let fn = function () {
                console.log(this);
                return this.firstName+this.lastName;
            }
            return fn();
        }
    }
    Person.getFullName();

    let Person2 = {
        firstName: '张',
        lastName: "飞",
        getFullName:function () {
            console.log(this);
            let first = this.firstName;
            console.log(first);
            let fn = () => {
                console.log(this);
                return this.firstName+this.lastName;
            }
            return fn();
        }
    }
 let name =   Person2.getFullName();
    console.log(name)
</script>
</body>
</html>